package logic

import (
	"activity_srv/activity"
	"activity_srv/internal/dao"
	"activity_srv/internal/svc"
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
)

type GeneratePosterLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGeneratePosterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GeneratePosterLogic {
	return &GeneratePosterLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 生成二级分销海报
func (l *GeneratePosterLogic) GeneratePoster(in *activity.GeneratePosterReq) (*activity.GeneratePosterResponse, error) {
	//业务逻辑
	generatePoster, err := dao.GeneratePoster(in)
	if err != nil {
		pkg.Error("生成海报失败", zap.Error(err))
		return &activity.GeneratePosterResponse{}, err
	}
	pkg.Info("生成海报成功", zap.Any("generatePoster", generatePoster))

	return &activity.GeneratePosterResponse{
		PosterUrl: generatePoster,
		Message:   "生成海报成功",
	}, nil
}
